建表语句.sql 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopEvententry]') AND type in (N'U'))
  2. begin
  3. CREATE TABLE [dbo].[tb_ErpShopEvententry](
  4. [ID] [int] identity(1,1) primary key not null, --ID主建
  5. [Matter_CreateName] [varchar](16) not null, --申请人
  6. [Matter_CreateDatetime] [Datetime] not null, --申请时间
  7. [Matter_content] [varchar](200)not null, --申请内容
  8. [Matter_state] [varchar](10)not null, --申请状态
  9. [Matter_UpdateName] [varchar](16)not null, --审批人
  10. [Matter_UpdateDatetime] [Datetime], --审核时间
  11. [Matter_opinion] [varchar](200) --审批人意见
  12. )
  13. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'ID主建' ,
  14. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  15. @level2type=N'COLUMN',@level2name=N'ID'
  16. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请人' ,
  17. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  18. @level2type=N'COLUMN',@level2name=N'Matter_CreateName'
  19. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请时间' ,
  20. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  21. @level2type=N'COLUMN',@level2name=N'Matter_CreateDatetime'
  22. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请内容' ,
  23. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  24. @level2type=N'COLUMN',@level2name=N'Matter_content'
  25. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请状态' ,
  26. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  27. @level2type=N'COLUMN',@level2name=N'Matter_state'
  28. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批人' ,
  29. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  30. @level2type=N'COLUMN',@level2name=N'Matter_UpdateName'
  31. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批时间' ,
  32. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  33. @level2type=N'COLUMN',@level2name=N'Matter_UpdateDatetime'
  34. EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批人意见' ,
  35. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
  36. @level2type=N'COLUMN',@level2name=N'Matter_opinion'
  37. end
  38. GO
  39. --公告表
  40. IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopBulletin]') AND type in (N'U'))
  41. begin
  42. CREATE TABLE [dbo].[tb_ErpShopBulletin](
  43. [ID] [int] identity(1,1) primary key not null, --ID主建
  44. [Bulletin_issuerID] [varchar](26) not null, --发布人ID
  45. [Bulletin_announcement] [varchar](100) not null, --公告类型
  46. [Bulletin_Title] [varchar](150)not null, --标题
  47. [Bulletin_content] [varchar](1000)not null, --内容
  48. [Bulletin_ReleaseTime] [Datetime] not null, --发布时间
  49. [Bulletin_Accessory] [varchar](200) --附件位置
  50. )
  51. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID主建' ,
  52. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  53. @level2type=N'COLUMN',@level2name=N'ID'
  54. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发布人ID' ,
  55. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  56. @level2type=N'COLUMN',@level2name=N'Bulletin_issuerID'
  57. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公告类型' ,
  58. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  59. @level2type=N'COLUMN',@level2name=N'Bulletin_announcement'
  60. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,
  61. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  62. @level2type=N'COLUMN',@level2name=N'Bulletin_Title'
  63. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' ,
  64. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  65. @level2type=N'COLUMN',@level2name=N'Bulletin_content'
  66. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发布时间' ,
  67. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  68. @level2type=N'COLUMN',@level2name=N'Bulletin_ReleaseTime'
  69. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'附件位置' ,
  70. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ ErpBulletin',
  71. @level2type=N'COLUMN',@level2name=N'Bulletin_Accessory'
  72. end
  73. GO
  74. IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopDesignatedAnnounced]') AND type in (N'U'))
  75. begin
  76. --指定人员查看表
  77. CREATE TABLE [dbo].[tb_ErpShopDesignatedAnnounced](
  78. [ID] [int] identity(1,1) primary key not null, --ID主建
  79. [Announced_issuerID] [varchar](26) not null, --指定人员查看公告ID
  80. [Announced_announcement] [varchar](100) not null, --公告ID
  81. )
  82. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID主建' ,
  83. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpDesignatedAnnounced',
  84. @level2type=N'COLUMN',@level2name=N'ID'
  85. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'指定人员查看公告ID' ,
  86. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpDesignatedAnnounced',
  87. @level2type=N'COLUMN',@level2name=N'Announced_issuerID'
  88. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公告ID' ,
  89. @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpDesignatedAnnounced',
  90. @level2type=N'COLUMN',@level2name=N'Announced_announcement'
  91. end
  92. GO
  93. IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View_Shopannouncement]'))
  94. begin
  95. DROP VIEW [dbo].[View_Shopannouncement]
  96. end
  97. GO
  98. --公告与指定人员视图
  99. Create view View_ShopAnnouncement
  100. AS
  101. select a.ID,
  102. a.Announced_issuerID,
  103. a.Announced_announcement,
  104. b.ID as 'Uid',
  105. b.Bulletin_issuerID,
  106. b.Bulletin_announcement,
  107. b.Bulletin_Title,
  108. b.Bulletin_content,
  109. b.Bulletin_ReleaseTime,
  110. b.Bulletin_Accessory from tb_ErpDesignatedAnnounced a Left JOIN
  111. tb_ErpBulletin b on a.Announced_announcement=b.ID
  112. GO